﻿#include "confess.h"
#include "ui_confess.h"
#include <QMouseEvent>
#include <QDebug>
#include <QMessageBox>
#include <QMediaPlayer>
#include <QPixmap>
#pragma execution_character_set("utf-8")
/*
 * Design By 威海
 * 原创首发
 * */
Confess::Confess(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Confess)
{
    ui->setupUi(this);
    setWindowFlags(windowFlags()&~Qt::WindowMaximizeButtonHint);    // 禁止最大化按钮
    setWindowFlags(windowFlags()&~Qt::WindowCloseButtonHint&~Qt::WindowContextHelpButtonHint);//禁止退出按钮
    setFixedSize(this->width(),this->height());                     // 禁止拖动窗口大小
    setWindowTitle("做我女朋友吧");
    setWindowIcon(QIcon("://love.ico"));
    msgBox2 = new QMessageBox(QMessageBox::NoIcon,"再想想吧！","想好了吗,再考虑考虑吧");
//    QPixmap *pixmap = new QPixmap("://flower.png");
//    ui->label_3->setPixmap(pixmap);
    ui->labelImage->setPixmap(QPixmap("://flower.png"));
    ui->labelImage->setScaledContents(true);
}

Confess::~Confess()
{
    delete ui;
}

void Confess::closeEvent(QCloseEvent *closeevent)
{
//    QString ret = QMessageBox::warning(this, "不要离开好吗", "关闭窗口也改变不了你喜欢我的事实");
//    if(ret == QMessageBox::Ok){
//        //关闭窗口
//        //处理关闭窗口事件，接收事件，事件就不会再往下传递
//        //closeevent->accept();
//        closeevent->ignore();
//    }
//    else if(ret == QMessageBox::Close){
//        //不关闭窗口
//        //忽略事件，事件继续给父组件传递
//        closeevent->accept();
//    }
}

//答应槽函数
void Confess::on_pushButton_clicked()
{
//    QMediaPlayer *player = new QMediaPlayer();
//    //播放音乐的
//    connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
//    player->setMedia(QUrl::fromLocalFile(""));
//    player->play();

    dia.show();
    this->close();

}

//拒绝槽函数
void Confess::on_pushButton_2_clicked()
{
    ui->pushButton_2->move(pushButton_2x,pushButton_2y += 30);
   // msgBox2->setMinimumSize(60,40);

    if(x_num == 0){
        msgBox2->setText("巧克力给你");
        msgBox2->setWindowIcon(QIcon("://love.ico"));
        x_num++;
    }else if(x_num == 1){
        msgBox2->setText("工资都给你");
        msgBox2->setWindowIcon(QIcon("://love.ico"));
        x_num++;
    }else if(x_num == 2){
        msgBox2->setText("房产证写你名");
        msgBox2->setWindowIcon(QIcon("://love.ico"));
        x_num++;
    }else if(x_num == 3){
        msgBox2->setText("我妈会游泳！");
        msgBox2->setWindowIcon(QIcon("://love.ico"));
        x_num++;
    }else if(x_num == 4){
        msgBox2->setText("爱你哦♥");
        msgBox2->setWindowIcon(QIcon("://love.ico"));
        x_num++;
    }else if(x_num == 5){
        msgBox2->setText("♥么么哒♥♥");
        msgBox2->setWindowIcon(QIcon("://love.ico"));
        x_num++;
    }else if(x_num == 6){
        msgBox2->setText("<font size='18' color='red'>你忍心拒绝我吗？~</font>");
        msgBox2->setWindowIcon(QIcon("://love.ico"));
        x_num++;
    }else if(x_num == 7){
        msgBox2->setText("<font size='20' color='red'>你赶快答应哦！！~</font>");
        msgBox2->setWindowIcon(QIcon("://love.ico"));
        x_num++;
    }

    msgBox2->show();
}
